﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace BestPracticesParts.StringConsumer
{
    [ToolboxItemAttribute(false)]
    public class StringConsumer : WebPart
    {
        BestPracticesParts.IStringConnection providerPart = null;

        [ConnectionConsumer("String Consumer")]
        public void GetConnectionInterface(
                           BestPracticesParts.IStringConnection ProviderPart)
        {
            this.providerPart = ProviderPart;
        }

        protected override void RenderContents(HtmlTextWriter writer)
        {
            try
            {
                writer.Write("<p>" + providerPart.ProvidedString + "</p>");
            }
            catch
            {
                writer.Write(
                 @"<img src='/_layouts/images/BestPracticesImages/delete.gif'/>"
                            );
            }
        }

    }


}
